#include <iostream>
using namespace std;
typedef long long ll;
const int N = 1e5+10;	

ll n, a[N];

int main()
{
	cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i], a[i]+=a[i-1];
	int m; cin >> m;
	while(m--)
	{
		int l, r;
		cin >> l >> r;
		cout << a[r]-a[l-1] << endl;
	}
	return 0;
}